
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head lang="en">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="__PUBLIC__/NewsAdmin/css/style.css">
    <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.2.0/css/bootstrap.css">
    <![if !IE]><script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.js"></script><![endif]>
    <!--[if IE]> <script src="http://apps.bdimg.com/libs/jquery/1.9.0/jquery.js"></script> <![endif]-->
    <script src="__PUBLIC__/NewsAdmin/js/style.js"></script>
    <title>新闻管理</title>
    <style>
        table {
            width: 100%;
            max-width: 100%;
            margin-bottom: 20px;
            border-spacing: 0;
            border-collapse: collapse;
        }
        tr{
            border-top:1px solid #FFF;
            border-bottom:1px solid #FFF;
            border-radius: 5px;
        }
        td{
            padding: 8px;
            line-height: 1.42857143;
            vertical-align: top;
            border-top: 1px solid #ddd;
        }
        select > option{
           padding-top:50px;
            padding-bottom: 50px;;
        }
        .digg{
            /*width: auto;*/
            position: fixed;
            bottom: 15px;
            left:0;
            right: 0;
            /*margin:auto;*/
            list-style: none;
            width: 100%;
            margin: auto 50%;
        }
        .digg > .li{
            width:20px;height: 20px;
            line-height: 20px;
            border:1px solid blue;
            float: left;
            margin-left:10px;
        }
        .digg > .li:hover{
            border:1px solid red;
        }
        .digg > .li > .a{
            padding:5px;
        }
	.pagination {
        /*position: absolute;*/
        bottom: 15px;
    }
        a{
            color:#333;
        }
        a:hover{
            color:red;
            cursor: pointer;
        }
        table{
            margin-top:100px;
        }
        th{
            text-align:center;
        }
    </style>
</head>
<body style="background-image: url(http://public.weirongm.com/DaChongQing//NewsAdmin/images/bg.png); background-attachment: fixed; background-position: 50% 0%;">
<div style="  width: 120px;margin: 0 auto;  position: absolute;  top: 15px;  left: 30px;">
    <select style="width:120px;height:30px;border:0;background:#FFF" onchange="mbar(this)"><option>全部</option>
    <foreach name="column" item="column">
        <?php
                    if($column['id'] == $column_id){
                        echo "<option selected='selected' value=".U('News/NewsList',array('id'=>$column['id'])).">".$column['title']."</option>";
        }else{
        echo "<option  value=".U('News/NewsList',array('id'=>$column['id'])).">".$column['title']."</option>";
        }

        ?>

    </foreach>
</select>
</div>
<div class="news">
    <table class="table table-hover" cellpadding="0" cellspacing="0">
        <tr>
            <th>选择</th>
            <!--<th>排序</th>-->
            <th>ID</th>
            <th>排序</th>
            <th>标题</th>
            <th>点击量</th>
            <th>新闻类型</th>
            <th>更新时间</th>
            <th>操作</th>
        </tr>
        <foreach name="NewsList" item="NewsList">
            <tr>
                <td><input type="checkbox" name="checkbox_news"></td>
                <td>{$NewsList['id']}</td>
                <td><input type="text" value="{$NewsList['order']}" name="listorder" data-id="{$NewsList['id']}" class="listorder"><button type="button" id="order" style="display:none;width:40px;">OK</button></td>
                <td><a onclick="javascript:openwinx('http://weixin.weirongm.com/DaChongQing/News/content/id/{$NewsList["id"]}','_blank','340px','550px')" title="新闻标题" data-url="news_url" class="table_news_a">{$NewsList['title']}</a></td>
                <td>{$NewsList['see']}</td>
                <td>{$NewsList['column']|NewsType=###}</td>
                <td>{$NewsList['createtime']|timeFormat=###}</td>
                <td>
                    <a data-href="{:U('News/upd',array('id'=>$NewsList['id']))}" data-ask="update" class="table_news_a" data-id={$NewsList['id']} onclick="javascript:openwinx('http://weixin.weirongm.com/DaChongQing/News/upd/id/{$NewsList["id"]}','_blank','1200px','650px')" id="update">修改</a>
                    |
                    <a data-href="{:U('News/del',array('id'=>$NewsList['id']))}" data-url="update.html" data-ask="delete" class="table_news_a" id="delete">删除</a>
                </td>
            </tr>
        </foreach>

    </table>
    <nav style="position:absolute;bottom:20px;left:30%">
        <ul class="pagination">
            <li class="<?php if(I('page')-1 < 1){echo 'disabled';} ?>">
                <a href="?page={:I('page')-1}" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
        <?php

            for($i = 1 ; $i <= ceil($countpage/10);$i++){
                if($i == I('page')){
                    echo "<li class='active'><a class='a' aria-label='Previous' href='?page=".$i."'><span aria-hidden='true'>".$i."</span></a></li>";
                  }else{
                       echo "<li><a class='a' aria-label='Previous' href='?page=".$i."'><span aria-hidden='true'>".$i."</span></a></li>";
                  }
            }
        ?>
            <li class="<?php if(I('page')+1 > ceil($countpage/10)){echo 'disabled';} ?>">
                <a href="?page={:I('page')+1}" aria-label="Previous">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
    </ul>
    <!--<nav>-->
        <!--<ul class="pagination">-->
            <!--<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>-->
            <!--<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>-->
            <!--...-->
        <!--</ul>-->
    <!--</nav>-->
</div>
<div class="box-yes" style="display:none;box-shadow:0px 0px 15px #333;position: fixed;width:300px;height:150px;top:50%;left:50%;margin-top:-50px;margin-left:-150px;background:#FFF;border-radius: 5px;color:#333">
    <label style="display:block;margin-top:10px;margin-left: 0px;border-bottom: 1px solid #e5e5e5;padding-left: 10px;padding-bottom: 10px;">请输入你的管理密码</label>
    <input id="key" class="form-control" style="width: 279px;margin-right:10px;margin-top:20px;margin-left:10px;" type="password" name="key">
    <button id="yes" type="button" class="btn btn-info" style="margin: 15px 11px 15px 165px;">确认</button>
    <button id="c" type="button" class="btn btn-danger" style="">关闭</button>
</div>
</body>
<script>
    function mbar(sobj) {
        var docurl =sobj.options[sobj.selectedIndex].value;
        if (docurl != "") {
            window.location.href = docurl;
//            open(docurl,'_blank');
//            sobj.selectedIndex=0;
//            sobj.blur();
        }
    }
    $('#c').click(function(){
        $('.box-yes').toggle(300)
    })
    $(function(){
//        $('a[id=update]').click(function(){
//            var href = $(this).attr('data-href');
//            window.location.href=href;
////            $(".box-yes").toggle(300);
////            $("#yes").click(function(){
////                var key = $("#key").val();
////                $.ajax({
////                    type: "post",
////                    url: "{:U('NewsAdmin/IsOk')}",
////                    data: {key:key},
////                    dataType: "text",
////                    success: function(data){
////                        if(data == "1"){
////                            window.location.href=href;
////                        }else{
////                            alert(data);
////                        }
////                    }
////                });
////            })
////            window.location.href=href;
//        })
        $('a[id=delete]').click(function(){
            var href = $(this).attr('data-href');
            $(".box-yes").toggle(300);
            $("#yes").click(function(){
                var key = $("#key").val();
                $.ajax({
                    type: "post",
                    url: "{:U('NewsAdmin/IsOk')}",
                    data: {key:key},
                    dataType: "text",
                    success: function(data){
                        if(data == "1"){
                            window.location.href=href;
                        }else{
                            alert(data);
                        }
                    }
                });
            })
//            window.location.href=href;
        })
        $("input[class=listorder]").focus(function(){
            var list = $(this);
//            var button = list.parent().find('#order');
            $(this).parent().find('#order').show();
        })
        $('button[id=order]').click(function(){
            var list = $(this).parent().find('.listorder');
            var id = list.attr('data-id');
            var order = list.val();
            var aa = $(this);
            $.ajax({
                url:'{:U("News/UpdOrder")}',
                type:'post',
                dataType:'text',
                data:{id:id,order:order},
                success:function(data){
                    if(data == 1){
                        alert('更改成功');
                        aa.hide();
                    }else{
                        alert('数据操作出现了不知道名的错误！');
                    }
                }
            })
        })
    })
    function openwinx(url,name,w,h) {
        if(!w) w=screen.width-4;
        if(!h) h=screen.height-95;
        window.open(url,'_blank',"top=100,left=400,width=" + w + ",height=" + h + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
    }
</script>
</html>
